home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Mania 4
/
MacMania 4.toast
/
/
Demo's
/
Igor Demo Pro
/
1 PutContentsIn Igor Pro Folder
/
WaveMetrics Procedures
/
Analysis
/
Decimation
next >
Wrap
Text File
|
1995-12-28
|
2KB
|
49 lines
#pragma rtGlobals=1
// Version 1.01, 05/17/94 -- Used Wave/D instead of Wave in several places.
// Version 1.02, 08/08/94 -- Changed factor to (factor-1) in FDecimate. Previously, one extra point was being averaged.
// Version 1.10, 12/28/95 -- Updated for Igor Pro 3.0. Removed /D which is no longer needed.
// FDecimate(source, dest, factor)
// See Decimate below for usage.
Function FDecimate(source, destName, factor)
Wave source
String destName // String contains name of dest which may or may not already exist
Variable factor
Variable numPoints // number of points in output wave
Variable segWidth // width of source wave segment
// Clone source so that source and dest can be identical
Duplicate/O source, decimateTmpSource1
numPoints = numpnts(decimateTmpSource1) / factor
Duplicate/O decimateTmpSource1, $destName // keep same precision
Redimension/N=(numPoints) $destName // set number of points
CopyScales decimateTmpSource1, $destName // X scaling must cover same span
segWidth = (factor-1)*deltax(decimateTmpSource1)
Wave dw = $destName // Make compiler understand the next line as a wave assignment
dw = mean(decimateTmpSource1, x, x+segWidth)
KillWaves/Z decimateTmpSource1
End
// Decimate(source, dest, factor)
// Creates an output wave by averaging every n points of the input wave
// down to a one point in the output wave.
// Example:
// Make/N=1000 wave0; SetScale x 0, 5, wave0
// wave0 = sin(x) + gnoise(.1)
// Decimate("wave0", "wave1", 10)
Macro Decimate(sourceName, destName, factor)
String sourceName
Prompt sourceName, "Source Wave", popup WaveList("*", ";", "")
String destName
Prompt destName, "Destination Wave"
Variable factor=10
Prompt factor, "Decimation factor"
PauseUpdate; Silent 1
FDecimate($sourceName, destName, factor)
End